


function co(fn) {
    let gen = fn()

    function next(args) {
        let { value, done } = gen.next(args);
        if (done) return value
        if (value.then) {
            value.then(res => next(res))
        } else {
            next(args)
        }
    }

    next()
}